﻿using System;
using DC2010.Objects.Base;
using DC2010.Objects;
using DC2010.Objects.Data;

namespace DC2010.Effects
{
    public class P_RestoreAll_Effect : EffectLogic
    {
        public int counter;

        public P_RestoreAll_Effect(EffectData ed) : base(ed)
        {
            ShortName = "INCREASE STAT";
            LongName = "Effect increases/decreses specific stat for creature.";
            Id = "I_INCREASE_STAT_EFFECT";
            EffectType = EffectType.Pump;
        }

        public override bool CheckPumpCondition(BaseObject aTarget)
        {
            counter++;
            return (counter % 4)==0;
        }

        public override void Pump(BaseObject aTarget)
        {
            DateTime dtStart = DateTime.Now;
            int amount = Data.Params.Find(A => A.Key == "AMOUNT").Value.ToInt();

            
            {
                if (CheckPumpCondition(aTarget))
                {
                    if (aTarget is CreatureData)
                    {
                        CreatureData aCreature = (CreatureData)aTarget;

                        aCreature.Attributes.Health.Add(amount);
                        aCreature.Attributes.Mana.Add(amount);
                        aCreature.Attributes.Stamina.Add(amount);
                    }
                }

                if ((DateTime.Now - dtStart).TotalSeconds > 0)
                    log.Debug("P_RestoreAll_Effect::Pump() takes: " + (DateTime.Now - dtStart).TotalSeconds + " seconds");

            }
        }
    }
}
